package com.cj.gateway.service.impl;

import com.cj.common.exception.BaseException;
import com.cj.common.response.Result;
import com.cj.gateway.service.LoginFeignService;
import feign.Response;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Author cheng jun
 * @Description:
 * @Date 2021/5/26 11:31
 */
@Component
@Slf4j
public class LoginFeignFallbackFactory implements FallbackFactory<LoginFeignService> {
    @Override
    public LoginFeignService create(Throwable cause) {
        return new LoginFeignService() {
            @Override
            public Result login(@RequestBody Map<String, Object> map) {
                log.error(cause.getMessage());
                throw new BaseException("openfeign调用失败:login接口------------------------------------------");
            }

            @Override
            public Result logout() {
                log.error(cause.getMessage());
                throw new BaseException("openfeign调用失败:logout------------------------------------------");
            }
        };
    }
}
